package cn.icast.custom.protocol.message;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Data
public abstract class Message implements Serializable {

        public static Class<?> getMessageClass(int messageType) {
            return messageClasses.get(messageType);
        }

        private int sequenceId; //序号

        private int messageType; //指令类型

        public abstract int getMessageType();

        public static final int LoginRequestMessage = 0;//登录请求
        public static final int LoginResponseMessage = 1;//登录响应
        public static final int ChatRequestMessage = 2; //聊天的消息
        public static final int ChatResponseMessage = 3;//聊天的回应
        public static final int GroupCreateRequestMessage = 4;//创建聊天室
        public static final int GroupCreateResponseMessage = 5;//创建聊天室回应的是5
        public static final int GroupJoinRequestMessage = 6;//
        public static final int GroupJoinResponseMessage = 7;
        public static final int GroupQuitRequestMessage = 8;
        public static final int GroupQuitResponseMessage = 9;
        public static final int GroupChatRequestMessage = 10;
        public static final int GroupChatResponseMessage = 11;
        public static final int GroupMembersRequestMessage = 12;
        public static final int GroupMembersResponseMessage = 13;
        private static final Map<Integer, Class<?>> messageClasses = new HashMap<>();

        static {
            messageClasses.put(LoginRequestMessage, cn.icast.custom.protocol.message.LoginRequestMessage.class);
/*        messageClasses.put(LoginResponseMessage, LoginResponseMessage.class);
        messageClasses.put(ChatRequestMessage, ChatRequestMessage.class);
        messageClasses.put(ChatResponseMessage, ChatResponseMessage.class);
        messageClasses.put(GroupCreateRequestMessage, GroupCreateRequestMessage.class);
        messageClasses.put(GroupCreateResponseMessage, GroupCreateResponseMessage.class);
        messageClasses.put(GroupJoinRequestMessage, GroupJoinRequestMessage.class);
        messageClasses.put(GroupJoinResponseMessage, GroupJoinResponseMessage.class);
        messageClasses.put(GroupQuitRequestMessage, GroupQuitRequestMessage.class);
        messageClasses.put(GroupQuitResponseMessage, GroupQuitResponseMessage.class);
        messageClasses.put(GroupChatRequestMessage, GroupChatRequestMessage.class);
        messageClasses.put(GroupChatResponseMessage, GroupChatResponseMessage.class);
        messageClasses.put(GroupMembersRequestMessage, GroupMembersRequestMessage.class);
        messageClasses.put(GroupMembersResponseMessage, GroupMembersResponseMessage.class);*/
        }
    }
